package 我的Java学习_算法基础.day_05;

import static 我的Java学习_算法基础.day_05._070_巧妙翻转字符串.reverseString;

public class _076_将字符串中按单词翻转 {
    public static void main(String[] args) {
        String s ="here you Are";
        System.out.println(reverse(s));
    }
    private static String reverse(String s){
        String s1 = reverseString(s);   //翻转字符串
        StringBuilder sb = new StringBuilder();
        String[] words = s1.split("\\s");//得到逆序单词
        for(int i =0;i<words.length;i++){
            sb.append(reverseString(words[i])+" ");//翻转单词
        }
        return sb.deleteCharAt(sb.length()-1).toString();//删掉最后一个空格
    }
}
